﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using OA.Model;
using OA.DBUtility;
using System.Collections.Generic;

namespace OA.Manager
{
	/// <summary>
	/// 数据访问类:Employee
	/// </summary>
	public partial class EmployeeManager
	{
		private SqlService<EmployeeInfo> _sqlService = null;

        public EmployeeManager()
		{
            _sqlService = new SqlService<EmployeeInfo>();
        }

		#region  Method		

        /// <summary>
        /// 插入新记录
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public bool InsertEmployeeInfo(EmployeeInfo employeeInfo)
        {
            return _sqlService.SaveEntity(employeeInfo);
        }

        /// <summary>
        /// 根据打印任务ID获得打印任务信息
        /// </summary>
        /// <param name="taskID"></param>
        /// <returns></returns>
        public EmployeeInfo GetEmployeeInfoByID(int ID)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("ID", ID);
            return _sqlService.GetSingleByFields(dic, null);
        }

        /// <summary>
        /// 判断该打印任务是否存在
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public bool IsExistEmployeeInfo(EmployeeInfo employeeInfo)
        {
            return _sqlService.IsExist(employeeInfo);
        }

        /// <summary>
        /// 根据指定的字段更新，字段名是数据库中对应的名称
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <param name="needUpdateFields"></param>
        /// <returns></returns>
        public bool UpdateEmployeeInfo(EmployeeInfo employeeInfo, List<string> needUpdateFields)
        {
            return _sqlService.UpdateByFields(employeeInfo, needUpdateFields);
        }

        /// <summary>
        /// 删除该检查任务
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public bool DeleteEmployeeInfo(EmployeeInfo employeeInfo)
        {
            return _sqlService.DeleteEntity(employeeInfo);
        }
        
        /// <summary>
        /// 根据条件检索员工基本信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public DataTable GetEmployeeInfoLinkSearch( EmployeeInfo info, int pageIndex, int pageSize, ref int total)
        {
            return _sqlService.GetSearchPaged(info, pageIndex, pageSize, ref total);
        }

	    /// <summary>
        /// 得到所有的员工基本信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List<EmployeeInfo> GetAllEmployeeInfo(int pageIndex, int pageSize, out int total)
        {
            return _sqlService.GetPaged(pageIndex, pageSize, out total);
        }

	    #endregion  Method
	}
}

